home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Full / Paragon Drive Backup 9 / DB90_SE_x64.msi / Data1.cab / _EEB18C0F2FC449CDA0A3BF989FED292C < prev    next >
Text File  |  2004-02-07  |  25KB  |  1,305 lines

  1. //    WebHelp 5.10.002
  2. var gaChunks=new Array();
  3. var gaFakes=new Array();
  4. var gaDataCon=null;
  5. var gaData=new Array();
  6.  
  7. var gbFindCK=false;;
  8. var gbNeedCalc=false;
  9. var gbScrl=false;
  10. var gbProcess=false;
  11. var gbReady=false;
  12.  
  13. var gnCheck=0;
  14. var gnNum=0;
  15. var gnIns=-1;
  16. var gnLoad=0;
  17. var gnRef=-1;
  18. var gnMaxItems=0;
  19. var gnMaxMargin=32000;
  20. var gnNeeded=0;
  21. var gnNKI=-1;
  22. var gnRE=0;
  23. var gnScrlMgn=30;
  24. var gnSE=0;
  25. var gnVisible=0;
  26. var gnItems=0;
  27. var gnUHeight=1;
  28.  
  29. var gsBCK=null;
  30. var gsChK=null;
  31. var gsCK=null;
  32. var gsLoadingDivID="LoadingDiv";
  33. var gsLoadingMsg="Loading data, please wait...";
  34. var gsSKA=null;
  35. var gsSKB=null;
  36.  
  37. var gbLoadInfo=false;
  38.  
  39. function onLoadXMLError()
  40. {
  41.     if(gbLoadInfo)
  42.     {
  43.         var aChunk=new Array();
  44.         projReady(aChunk);
  45.     }
  46.     else
  47.     {
  48.         var aData=new Array();
  49.         putData(aData);
  50.     }
  51. }
  52.  
  53. function putDataXML(xmlDoc,sDocPath)
  54. {
  55.     if(gbLoadInfo)
  56.     {
  57.         var node=xmlDoc.lastChild;
  58.         if(node)
  59.         {
  60.             var nTotal=0
  61.             var aChunk=new Array();
  62.             var oC=node.firstChild;
  63.             while(oC)
  64.             {
  65.                 if(oC.nodeName=="chunkinfo")
  66.                 {
  67.                     var item=new Object();
  68.                     item.sBK=oC.getAttribute("first");
  69.                     item.sEK=oC.getAttribute("last");
  70.                     item.sFileName=oC.getAttribute("url");
  71.                     item.nNum=parseInt(oC.getAttribute("num"));
  72.                     nTotal+=item.nNum;
  73.                     item.nTotal=nTotal;
  74.                     aChunk[aChunk.length]=item;
  75.                 }
  76.                 oC=oC.nextSibling;
  77.             }
  78.             projReady(aChunk);
  79.         }
  80.     }
  81.     else
  82.     {
  83.         var node=xmlDoc.lastChild;
  84.         if(node)
  85.         {
  86.             var aData=new Array();
  87.             var nPrev=0;
  88.             var nNext=0;
  89.             var oC=node.firstChild;
  90.             while(oC)
  91.             {
  92.                 nPrev=nNext;
  93.                 if(oC.nodeName=="key")
  94.                 {
  95.                     var sName=oC.getAttribute("name");
  96.                     if(sName&&sName.length>0)
  97.                     {
  98.                         var sTarget=oC.getAttribute("target");
  99.                         var item=new Object();
  100.                         item.nType=2;
  101.                         item.sName=sName;
  102.                         if(sTarget)
  103.                             item.sTarget=sTarget;
  104.                         item.nPKOff=nPrev;
  105.                         aData[aData.length]=item;
  106.                         var nCurIndex=aData.length;
  107.                         processKey(oC,aData,item);
  108.                         nNext=aData.length-nCurIndex;
  109.                         item.nNKOff=nNext;
  110.                     }
  111.                 }
  112.                 else if(oC.nodeName=="letter")
  113.                 {
  114.                     var name=oC.getAttribute("name");
  115.                     if(name&&name.length>0)
  116.                     {
  117.                         var item=new Object();
  118.                         item.nType=1;
  119.                         item.sName=name;
  120.                         item.nPKOff=nPrev;
  121.                         nNext=0;
  122.                         item.nNKOff=nNext;
  123.                         aData[aData.length]=item;
  124.                     }
  125.                 }
  126.                 else if(oC.nodeName=="entry")
  127.                 {
  128.                     var name=oC.getAttribute("name");
  129.                     var def=oC.getAttribute("value");
  130.                     if(name&&name.length>0)
  131.                     {
  132.                         var item=new Object();
  133.                         item.sName=name;
  134.                         item.sDef=def;
  135.                         item.nPKOff=nPrev;
  136.                         nNext=0;
  137.                         item.nNKOff=nNext;
  138.                         aData[aData.length]=item;
  139.                     }
  140.                 }
  141.                 oC=oC.nextSibling;
  142.             }
  143.             putData(aData);
  144.         }
  145.     }
  146. }
  147.  
  148. function processKey(element,aData,item)
  149. {
  150.     var i=0;
  151.     var nPrev=0;
  152.     var nNext=0;
  153.     var oC=element.firstChild;
  154.     while(oC)
  155.     {
  156.         if(oC.nodeName=="topic")
  157.         {
  158.             var name=oC.getAttribute("name");
  159.             var url=oC.getAttribute("url");
  160.             if(url&&url.length!=0)
  161.             {
  162.                 if(!name||name.length==0)
  163.                     name=url;
  164.                 var topic=new Object();
  165.                 topic.sName=name;
  166.                 topic.sURL=url;
  167.                 if(!item.aTopics)
  168.                     item.aTopics=new Array();
  169.                 item.aTopics[item.aTopics.length]=topic;
  170.             }
  171.         }
  172.         else if(oC.nodeName=="key")
  173.         {
  174.             nPrev=nNext;
  175.             var name=oC.getAttribute("name");
  176.             if(name&&name.length!=0)
  177.             {
  178.                 var subItem=new Object();
  179.                 subItem.sName=name;
  180.                 subItem.nType=3;
  181.                 subItem.nPKOff=nPrev;
  182.                 aData[aData.length]=subItem;
  183.                 var nCurIndex=aData.length;
  184.                 processKey(oC,aData,subItem);
  185.                 nNext=aData.length-nCurIndex;
  186.                 subItem.nNKOff=nNext;
  187.             }
  188.         }
  189.         oC=oC.nextSibling;
  190.     }
  191. }
  192.  
  193. function putData(aData)
  194. {
  195.     endLoading();
  196.     var oCData=goCData;
  197.     if(oCData)
  198.     {
  199.         oCData.aKs=aData;
  200.         if(gnNKI==-1)
  201.             setTimeout("checkReady();",1);
  202.         else
  203.         {
  204.             gsSKA=getKByIdx(oCData,gnNKI);
  205.             gbNeedCalc=true;
  206.             gbScrl=true;
  207.             gnNKI=-1;
  208.             if(gsSKA)
  209.                 setTimeout("checkReady();",1);
  210.             else
  211.             {
  212.                 markEnd();
  213.                 setTimeout("checkAgain();",50);
  214.             }
  215.         }
  216.     }
  217. }
  218.  
  219. function markEnd()
  220. {
  221.     if(gbProcess)
  222.         gbProcess=false;
  223. }
  224.  
  225. function endLoading()
  226. {
  227.     var oDiv=getElement(gsLoadingDivID);
  228.     if(oDiv)
  229.         oDiv.style.visibility="hidden";
  230. }
  231.  
  232. function markBegin()
  233. {
  234.     gbProcess=true;
  235. }
  236.  
  237. function beginLoading()
  238. {
  239.     var oDiv=getElement(gsLoadingDivID);
  240.     if(oDiv)
  241.     {
  242.         oDiv.style.top=document.body.scrollTop;
  243.         oDiv.style.visibility="visible";
  244.     }
  245. }
  246.  
  247. function indexHTMLPart()
  248. {
  249.     this.sHTML="";
  250.     this.nNeeded=0;
  251.     this.nCurrent=0;
  252.     this.nConsumed=0;
  253.     this.sFK=null;
  254.     this.sLK=null;
  255.     this.addHTML=function(sHTML,nConsumed,bDown,bK,sK){
  256.         if(bDown)
  257.             this.sHTML+=sHTML;
  258.         else
  259.             this.sHTML=sHTML+this.sHTML;
  260.         this.nCurrent++;            
  261.         this.nConsumed+=nConsumed;
  262.         if(bK)
  263.         {
  264.             if(!this.sFK)
  265.                 this.sFK=sK;
  266.             if(!this.sLK)
  267.                 this.sLK=sK;
  268.             if(bDown)
  269.                 this.sLK=sK;
  270.             else
  271.                 this.sFK=sK;
  272.         }
  273.     }
  274.     this.appendHTML=function(oHTML,bDown){
  275.         this.addSubHTML(oHTML,bDown);
  276.         if(!this.sFK)
  277.             this.sFK=oHTML.sFK;
  278.         if(!this.sLK)
  279.             this.sLK=oHTML.sLK;
  280.         if(bDown)
  281.             this.sLK=oHTML.sLK;
  282.         else
  283.             this.sFK=oHTML.sFK;
  284.     }    
  285.     
  286.     this.addSubHTML=function(oHTML,bDown){
  287.         if(bDown)
  288.             this.sHTML+=oHTML.sHTML;
  289.         else
  290.             this.sHTML=oHTML.sHTML+this.sHTML;
  291.         this.nCurrent+=oHTML.nCurrent;
  292.         this.nConsumed+=oHTML.nConsumed;            
  293.     }
  294. }
  295.  
  296. function getMaxUnits()
  297. {
  298.     return Math.floor(gnMaxMargin/gnUHeight)+1;
  299. }
  300.  
  301. function getFakeItemsHTMLbyCount(nB,nCount)
  302. {
  303.     var nMU=getMaxUnits();
  304.     var nNum=Math.floor(nCount/nMU);
  305.     var sHTML="";
  306.     for(var i=0;i<nNum;i++)
  307.         sHTML+=getFakeItemHTML(nB,nMU-1);
  308.         
  309.     var nRest=nCount%nMU;
  310.     sHTML+=getFakeItemHTML(nB,nRest-1);
  311.     return sHTML;
  312. }
  313.  
  314. function getFakeItemHTML(nB,nNum)
  315. {
  316.     return "<h6 name=fk"+nB+" id=fk"+nB+" style=\"margin-top:"+gnUHeight*nNum+";margin-bottom:0\"> </h6>";
  317. }
  318.  
  319. function fakeItemsArea(nB,n,sKA,sKB,obj)
  320. {
  321.     this.nB=nB;
  322.     this.nNum=n;
  323.     this.sKA=sKA;
  324.     this.sKB=sKB;
  325.     this.obj=obj;
  326.     this.nMargin=(n-1)*gnUHeight;
  327.  
  328.     this.setNum=function(n)
  329.     {
  330.         var nLastobj=-1;
  331.         var nDelta=this.nMargin;
  332.         this.nMargin=(n-1)*gnUHeight;
  333.         nDelta=nDelta-this.nMargin;
  334.         if(n>0)
  335.         {
  336.             this.nNum=n;
  337.             var nMU=getMaxUnits();
  338.             nLastobj=Math.floor((n-1)/nMU);
  339.             if(this.obj.length)
  340.                 this.obj[nLastobj].style.marginTop=((n-1)%nMU)*gnUHeight;
  341.             else
  342.                 this.obj.style.marginTop=((n-1)%nMU)*gnUHeight;
  343.         }
  344.         if(this.obj.length)
  345.         {
  346.             for(var i=this.obj.length-1;i>nLastobj;i--)
  347.                 removeThis(this.obj[i]);
  348.         }
  349.         else
  350.         {
  351.             if(nLastobj==-1)
  352.                 removeThis(this.obj);
  353.         }
  354.         return nDelta;
  355.     }
  356.     this.insertAdjacentHTML=function(sWhere,sHTML)
  357.     {
  358.         if(sWhere=="beforeBegin")
  359.         {
  360.             if(this.obj.length)
  361.                 this.obj[0].insertAdjacentHTML(sWhere,sHTML);
  362.             else
  363.                 this.obj.insertAdjacentHTML(sWhere,sHTML);
  364.         }
  365.         else if(sWhere=="afterEnd")
  366.         {
  367.             if(this.obj.length)
  368.             {
  369.                 if(gbMac&&gbIE5&&this.obj[this.obj.length-1].nextSibling)
  370.                     this.obj[this.obj.length-1].nextSibling.insertAdjacentHTML("beforeBegin",sHTML);
  371.                 else
  372.                     this.obj[this.obj.length-1].insertAdjacentHTML(sWhere,sHTML);
  373.             }
  374.             else
  375.             {
  376.                 if(gbMac&&gbIE5&&this.obj.nextSibling)
  377.                     this.obj.nextSibling.insertAdjacentHTML("beforeBegin",sHTML);
  378.                 else
  379.                     this.obj.insertAdjacentHTML(sWhere,sHTML);
  380.             }
  381.         }
  382.     }
  383.     this.getBtm=function()
  384.     {
  385.         if(this.obj.length)
  386.             return this.obj[this.obj.length-1].offsetTop;
  387.         else
  388.             return this.obj.offsetTop;
  389.     }
  390.     this.getTop=function()
  391.     {
  392.         return this.getBtm()-this.nMargin;
  393.     }
  394. }
  395.  
  396. function usedItems(nB,nE)
  397. {
  398.     this.nB=nB;
  399.     this.nE=nE;
  400.     this.oN=null;
  401. }
  402.  
  403. function checkReady()
  404. {
  405.     var len=gaChunks.length;
  406.     var bNeedLoad=false;
  407.     var aDataCon;
  408.     var s=0;
  409.     var bDown=(gsSKB==null);
  410.     var sK=bDown?gsSKA:gsSKB;
  411.     if(sK==null)
  412.     {
  413.         markEnd();
  414.         setTimeout("checkAgain();",50);
  415.         return;
  416.     }
  417.     if(!gsChK||sK!=gsChK||gnNum==0)
  418.     {
  419.         gnCheck=0;
  420.         gsChK=sK;
  421.         aDataCon=new Array();
  422.     }
  423.     else{
  424.         s=gnNum;
  425.         aDataCon=gaDataCon;
  426.     }
  427.     for(var i=gnCheck;i<len;i++)
  428.     {
  429.         var oCData=getChunkedData(i,bDown,sK);
  430.         if(oCData)
  431.         {
  432.             if(!oCData.aKs&&oCData.sFileName!=null)
  433.             {
  434.                 bNeedLoad=true;
  435.                 goCData=oCData;
  436.                 gnNum=s;
  437.                 gnCheck=i;
  438.                 gaDataCon=aDataCon;
  439.                 oCData.nProjId=i;
  440.                 gbLoadInfo=false;
  441.                 beginLoading();
  442.                 loadData2(gaData[i].sPPath+gaData[i].sDPath+oCData.sFileName);
  443.                 return;
  444.             }
  445.             else{
  446.                 aDataCon[s++]=oCData;
  447.             }
  448.         }
  449.     }
  450.     if(!bNeedLoad)
  451.     {
  452.         gnNum=0;
  453.         gsSKA=gsSKB=gsShowK=null;
  454.         
  455.         var oHTML=new indexHTMLPart();
  456.         var aPos=new Array();
  457.         var aOriPos=new Array();
  458.         var aMaxPos=new Array();
  459.         var aMinPos=new Array();
  460.         
  461.         if(gbNeedCalc||gbFindCK) gnIns=0;
  462.         for(i=0;i<aDataCon.length;i++)
  463.         {
  464.             aPos[i]=getIdxPos(aDataCon[i],bDown,sK);
  465.             if(gbNeedCalc||gbFindCK)
  466.             {
  467.                 gnIns+=aPos[i]+aDataCon[i].nTotal-aDataCon[i].nNum;
  468.                 if(!bDown)
  469.                 {
  470.                     if(aPos[i]!=-1)
  471.                     {
  472.                         if(aDataCon[i].aKs)
  473.                             gnIns+=aDataCon[i].aKs[aPos[i]].nNKOff;
  474.                         else
  475.                         {
  476.                             var n=aPos[i]+1;
  477.                             while(n<aDataCon[i].aKsOnly.length&&!aDataCon[i].aKsOnly[n])
  478.                                 n++;
  479.                             n=n-aPos[i]-1;
  480.                             gnIns+=n;
  481.                         }
  482.                     }
  483.                 }
  484.             }
  485.             aOriPos[i]=aPos[i];
  486.             getLimit(aDataCon,aPos,aMaxPos,aMinPos,i);
  487.         }
  488.         if((gbNeedCalc||gbFindCK)&&!bDown&&gnIns!=-1)
  489.         {
  490.             gnIns+=(aDataCon.length-1)
  491.         }
  492.         if(gnIns!=-1||gbFindCK)
  493.         {
  494.             oHTML.nNeeded=gnNeeded;
  495.             var bDone=writeItems(oHTML,aDataCon,aPos,aMinPos,aMaxPos,bDown,1);
  496.             if(oHTML.nConsumed!=0)
  497.             {
  498.                 var nB;
  499.                 if(!bDown)
  500.                     nB=gnIns-oHTML.nConsumed+1;
  501.                 else
  502.                     nB=gnIns;
  503.                     
  504.                 var oldScrollPos=document.body.scrollTop;
  505.                 if(insertIdxKs(nB,oHTML,gbScrl))
  506.                 {
  507.                     updateUsedK(aDataCon,aOriPos,aPos,bDown);
  508.                     if(!gbScrl&&gbMac)
  509.                     {
  510.                         while(document.body.scrollTop!=oldScrollPos)
  511.                             document.body.scrollTop=oldScrollPos;
  512.                     }
  513.                     gbScrl=false;
  514.                 }
  515.                 if(gbFindCK)
  516.                 {
  517.                     gbFindCK=false;
  518.                     gbNeedCalc=true;
  519.                     gsSKB=oHTML.sFK;
  520.                     gnIns=-1;
  521.                     setTimeout("checkReady();",50);
  522.                     return;
  523.                 }
  524.             }
  525.             else if(gbFindCK)
  526.             {
  527.                 gbFindCK=false;
  528.                 gbNeedCalc=true;
  529.                 gsSKB=getFirstKeyFromPos(aDataCon,aPos);
  530.                 gnIns=-1;
  531.                 setTimeout("checkReady();",50);
  532.                 return;
  533.             }
  534.             if(!findCKInDom()) return;
  535.  
  536.             gnNeeded=gnNeeded-oHTML.nCurrent;
  537.             gnIns=-1;
  538.             markEnd();
  539.             setTimeout("checkAgain();",50);
  540.             gbNeedCalc=false;
  541.         }
  542.         else
  543.         {
  544.             if(!findCKInDom()) return;
  545.             markEnd();
  546.             setTimeout("checkAgain();",50);
  547.         }
  548.     }
  549. }
  550.  
  551. function getFirstKeyFromPos(aDataCon,aPos)
  552. {
  553.     var sCurrentK=getBiggestChar();
  554.     for(var i=0;i<aPos.length;i++)
  555.     {
  556.         if(aDataCon[i].aKs&&aDataCon[i].aKs.length>0&&aPos[i]>=0&&aPos[i]<aDataCon[i].aKs.length)
  557.         {
  558.             if(sCurrentK==""||
  559.                 compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)>0)
  560.             {
  561.                 sCurrentK=aDataCon[i].aKs[aPos[i]].sName;
  562.             }
  563.         }
  564.     }
  565.     return sCurrentK;
  566. }
  567.  
  568. function checkAgain()
  569. {
  570.     if(!gbProcess)
  571.     {
  572.         if(gsBCK!=null)
  573.         {
  574.             gsCK=gsBCK;
  575.             gsBCK=null;
  576.             findCK();
  577.         }
  578.         else
  579.         {
  580.             markBegin();
  581.             getUnitIdx(document.body.scrollTop,document.body.clientHeight);
  582.         }
  583.     }
  584.     else
  585.         setTimeout("checkAgain()",50);
  586. }
  587.  
  588. function getLimit(aDataCon,aPos,aMaxPos,aMinPos,i)
  589. {
  590.     aMaxPos[i]=aDataCon[i].nNum;
  591.     aMinPos[i]=-1;
  592.     var oPNode=null;
  593.     if(aDataCon[i].oUsedItems)
  594.     {
  595.         var oUsedItems=aDataCon[i].oUsedItems;
  596.         do{
  597.             if(oUsedItems.nB>aPos[i])
  598.             {
  599.                 aMaxPos[i]=oUsedItems.nB;
  600.                 break;
  601.             }
  602.             oPNode=oUsedItems;
  603.             oUsedItems=oUsedItems.oN;
  604.         }while(oUsedItems!=null);
  605.         if(oPNode)
  606.             aMinPos[i]=oPNode.nE;
  607.     }
  608.     else if(aDataCon[i].aKs==null)
  609.     {
  610.         aMaxPos[i]=aMinPos[i]=aPos[i];
  611.     }
  612.     if(aMinPos[i]>=aPos[i]||aMaxPos[i]<=aPos[i])
  613.     {
  614.         aMaxPos[i]=aMinPos[i]=aPos[i];
  615.     }
  616. }
  617.  
  618. function getIdxPos(oIdx,bDown,sK)
  619. {
  620.     var aKs=oIdx.aKs;
  621.     var nIdx;
  622.     if(bDown)
  623.         nIdx=oIdx.nNum;
  624.     else
  625.         nIdx=-1;
  626.     if(aKs!=null)
  627.     {
  628.         for(var i=0;i<aKs.length;i++)
  629.         {    
  630.             if(bDown)
  631.             {
  632.                 if(compare(aKs[i].sName,sK)>0)
  633.                 {
  634.                     nIdx=i;
  635.                     break;
  636.                 }
  637.             }
  638.             else
  639.             {
  640.                 if(compare(aKs[i].sName,sK)<0)
  641.                     nIdx=i;
  642.                 else
  643.                     break;
  644.             }
  645.             i+=aKs[i].nNKOff;
  646.         }
  647.     }
  648.     else if(oIdx.aKsOnly)
  649.     {
  650.         var aKsOnly=oIdx.aKsOnly;
  651.         for(var i=0;i<aKsOnly.length;i++)
  652.         {    
  653.             if(aKsOnly[i])
  654.             {
  655.                 if(bDown)
  656.                 {
  657.                     if(compare(aKsOnly[i],sK)>0)
  658.                     {
  659.                         nIdx=i;
  660.                         break;
  661.                     }
  662.                 }
  663.                 else
  664.                 {
  665.                     if(compare(aKsOnly[i],sK)<0)
  666.                         nIdx=i;
  667.                     else
  668.                         break;
  669.                 }
  670.             }
  671.         }
  672.     }
  673.     return nIdx;
  674. }
  675.  
  676. function writeItems(oHTML,aDataCon,aPos,aMinPos,aMaxPos,bDown,nLevel)
  677. {
  678.     var aOldPos=new Array();
  679.     for(var i=0;i<aPos.length;i++)
  680.     {
  681.         aOldPos[i]=aPos[i];
  682.     }
  683.     var p;
  684.     do{
  685.         var sCurrentK="";
  686.         var aCurIdxSet=new Array();
  687.         p=0;
  688.         for(i=0;i<aDataCon.length;i++)
  689.         {
  690.             if(aDataCon[i].aKs&&aDataCon[i].aKs.length&&aPos[i]!=-1&&
  691.                 (bDown&&aPos[i]<aMaxPos[i])||(!bDown&&aPos[i]>aMinPos[i]))
  692.             {
  693.                 if(sCurrentK==""||
  694.                     (bDown&&compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)>0)||
  695.                     (!bDown&&compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)<0))
  696.                 {
  697.                     sCurrentK=aDataCon[i].aKs[aPos[i]].sName;
  698.                     p=0;
  699.                     aCurIdxSet[p++]=i;
  700.                 }
  701.                 else if(compare(sCurrentK,aDataCon[i].aKs[aPos[i]].sName)==0){
  702.                     aCurIdxSet[p++]=i;
  703.                 }
  704.             }
  705.             else if(nLevel==1&&aMaxPos[i]!=aMinPos[i]){
  706.                 if(bDown&&aPos[i]==aMaxPos[i])
  707.                 {
  708.                     if(aDataCon[i].aKs)
  709.                     {
  710.                         gsSKA=aDataCon[i].aKs[aOldPos[i]].sName;
  711.                         return false;
  712.                     }
  713.                 }
  714.                 else if(!bDown&&aPos[i]==aMinPos[i])
  715.                 {
  716.                     if(aDataCon[i].aKs)
  717.                     {
  718.                         gsSKB=aDataCon[i].aKs[aOldPos[i]].sName;
  719.                         return false;
  720.                     }
  721.                 }
  722.             }
  723.         }
  724.         if(p>=1){
  725.             for(var s=0;s<p;s++)
  726.             {
  727.                 aOldPos[aCurIdxSet[s]]=aPos[aCurIdxSet[s]];
  728.             }
  729.             mergeItems(oHTML,bDown,aDataCon,aCurIdxSet,p,aPos,nLevel);
  730.             adjustPosition(bDown,aDataCon,aCurIdxSet,p,aPos);
  731.             
  732.             if(nLevel==1&&oHTML.nNeeded<=oHTML.nCurrent){
  733.                 return true;
  734.             }
  735.         }
  736.     }while(p>0);
  737.     return true;
  738. }
  739.  
  740. function updateUsedK(aDataCon,aOriPos,aOldPos,bDown)
  741. {
  742.     for(var i=0;i<aDataCon.length;i++)
  743.     {
  744.         if (aOldPos[i]!=aOriPos[i])
  745.         {
  746.             var nBP=0;
  747.             var nEP=0;
  748.             if(bDown)
  749.             {
  750.                 nBP=aOriPos[i];
  751.                 nEP=aOldPos[i]-1;
  752.             }
  753.             else
  754.             {
  755.                 if (aOldPos[i]!=-1)
  756.                     nBP=aOldPos[i]+aDataCon[i].aKs[aOldPos[i]].nNKOff+1;
  757.                 else
  758.                     nBP=0;
  759.                 nEP=aOriPos[i]+aDataCon[i].aKs[aOriPos[i]].nNKOff;
  760.             }
  761.             if(nBP<=nEP)
  762.             {
  763.                 setContentsUsed(aDataCon[i],nBP,nEP);
  764.                 
  765.                 var oFirstPair=aDataCon[i].oUsedItems;
  766.                 if(oFirstPair.oN==null&&oFirstPair.nB==0&&oFirstPair.nE==aDataCon[i].nNum-1)
  767.                 {
  768.                     storeKeysOnly(aDataCon[i]);
  769.                     aDataCon[i].oUsedItems=aDataCon[i].aKs=aDataCon[i].sFileName=null;
  770.                 }
  771.             }
  772.         }
  773.     }
  774. }
  775.  
  776. function storeKeysOnly(oCData)
  777. {
  778.     oCData.aKsOnly=new Array();
  779.     for(var i=0;i<oCData.aKs.length;i++)
  780.     {
  781.         oCData.aKsOnly[i]=oCData.aKs[i].sName;
  782.         i+=oCData.aKs[i].nNKOff;
  783.     }
  784. }
  785.  
  786. function setContentsUsed(oIdx,nB,nE)
  787. {
  788.     if(!oIdx.oUsedItems)
  789.         oIdx.oUsedItems=new usedItems(nB,nE);
  790.     else
  791.     {
  792.         var oUsedItems=oIdx.oUsedItems;
  793.         var oPNode=null;
  794.         do{
  795.             if(oUsedItems.nB>nB)
  796.             {
  797.                 if(oUsedItems.nB==nE+1)
  798.                 {
  799.                     oUsedItems.nB=nB;
  800.                 }
  801.                 else{
  802.                     var oNewNode=new usedItems(oUsedItems.nB,oUsedItems.nE);
  803.                     oNewNode.oN=oUsedItems.oN;
  804.                     oUsedItems.nB=nB;
  805.                     oUsedItems.nE=nE;
  806.                     oUsedItems.oN=oNewNode;
  807.                 }
  808.                 break;
  809.             }
  810.             oPNode=oUsedItems;
  811.             oUsedItems=oUsedItems.oN;
  812.         }while(oUsedItems);
  813.         if(!oUsedItems)
  814.         {
  815.             if(oPNode!=null)
  816.                 oPNode.oN=new usedItems(nB,nE);
  817.         }
  818.         if(oPNode!=null){
  819.             if(oPNode.nE==oPNode.oN.nB-1)
  820.             {
  821.                 oPNode.nE=oPNode.oN.nE;
  822.                 oPNode.oN=oPNode.oN.oN;
  823.             }
  824.         }
  825.     }
  826. }
  827.  
  828. function projInfo(sPPath,sDPath,sFile)
  829. {
  830.     this.sPPath=sPPath;
  831.     this.sDPath=sDPath;
  832.     this.sFile=sFile;
  833. }
  834.  
  835. function addProjInfo(sPPath,sDPath,sFile)
  836. {
  837.     var oIdxInfo=new projInfo(sPPath,sDPath,sFile);
  838.     gaData[gaData.length]=oIdxInfo;
  839.     return oIdxInfo;
  840. }
  841.  
  842. function writeDataIFrame()
  843. {
  844.     if(gnLoad<gaData.length)
  845.     {
  846.         gbLoadInfo=true;
  847.         loadData2(gaData[gnLoad].sPPath+gaData[gnLoad].sDPath+gaData[gnLoad].sFile);
  848.     }
  849.     else{
  850.         if(gnItems!=0)
  851.         {
  852.             markBegin();
  853.             writeFakeItems();
  854.             gsSKA="";
  855.             gnNeeded=gnVisible;
  856.             gnIns=0;
  857.             checkReady();
  858.         }
  859.     }
  860. }
  861.  
  862. function getH6ById(nPos)
  863. {
  864.     if(document.all)
  865.         return document.all("fk"+nPos);
  866.     else if(document.getElementsByName)
  867.         return document.getElementsByName("fk"+nPos);
  868.     return null;        
  869. }
  870.  
  871. function showItemsInEvaluation(nBP)
  872. {
  873.     var bRtn=true;
  874.     var fPer=nBP/gnItems;
  875.     var nB=Math.floor(fPer*gnMaxItems);
  876.     var oCData=getChunkByIdx(gnRef,nB);
  877.     if(oCData)
  878.     {
  879.         if(!oCData.aKs&&oCData.sFileName!=null)
  880.         {
  881.             gnNKI=nB;
  882.             goCData=oCData;
  883.             oCData.nProjId=gnRef;
  884.             gbLoadInfo=false;
  885.             beginLoading();
  886.             loadData2(gaData[gnRef].sPPath+gaData[gnRef].sDPath+oCData.sFileName);
  887.         }
  888.         else{
  889.             gsSKA=getKByIdx(oCData,nB);
  890.             if(gsSKA)
  891.             {
  892.                 gsSKB=null;
  893.                 gbNeedCalc=true;
  894.                 gbScrl=true;
  895.                 checkReady()
  896.             }
  897.             else
  898.             {
  899.                 markEnd();
  900.                 bRtn=false;
  901.             }
  902.         }
  903.     }
  904.     else
  905.     {
  906.         markEnd();
  907.         bRtn=false;
  908.     }
  909.     return bRtn;
  910. }
  911.  
  912. function isUsed(oCData,nPos)
  913. {
  914.     var oUsed=oCData.oUsedItems;
  915.     while(oUsed&&oUsed.nB<=nPos)
  916.     {
  917.         if(oUsed.nE>=nPos) return true;
  918.         oUsed=oUsed.oN;
  919.     }
  920.     return false;
  921. }
  922.  
  923. function getKByIdx(oCData,nB)
  924. {
  925.     var nRelPos=nB-(oCData.nTotal-oCData.nNum);
  926.     var aIKs=oCData.aKs;
  927.     if(nRelPos>=0&&aIKs&&nRelPos<aIKs.length)
  928.     {
  929.         var oK=null;
  930.         do{
  931.             oK=aIKs[nRelPos++];
  932.         }    
  933.         while((oK.nType==3||isUsed(oCData,nRelPos-1))&&nRelPos<aIKs.length);
  934.         if(oK.nType!=3)
  935.         {
  936.             return oK.sName;
  937.         }
  938.         else{
  939.             nRelPos=nB-(oCData.nTotal-oCData.nNum)-1;
  940.             if(nRelPos>=0)
  941.             {
  942.                 do{
  943.                     oK=aIKs[nRelPos--];
  944.                 }
  945.                 while((oK.nType==3||isUsed(oCData,nRelPos+1))&&nRelPos>=0);
  946.             }
  947.             if(oK.nType!=3)
  948.             {
  949.                 return oK.sName;
  950.             }
  951.         }
  952.     }
  953.     return null;
  954. }
  955.  
  956. function loadData2(sFileName)
  957. {
  958.     disEvt();
  959.     if(gbXML)
  960.         loadDataXML(sFileName);
  961.     else
  962.         loadData(sFileName);
  963.     enEvt();
  964. }
  965.  
  966. function projReady(aChunk)
  967. {
  968.     gaChunks[gnLoad++]=aChunk;
  969.     var len=aChunk.length;
  970.     var nTotal=0;
  971.     if(len>0)
  972.         nTotal=aChunk[len-1].nTotal;
  973.     gnItems+=nTotal;
  974.     if(nTotal>gnMaxItems)
  975.     {
  976.         gnMaxItems=nTotal;
  977.         gnRef=gnLoad-1;
  978.     }
  979.     setTimeout("writeDataIFrame();",1);
  980. }
  981.  
  982. function writeFakeItems()
  983. {
  984.     disEvt();
  985.     gnUHeight=15;
  986.     var sHTML=getFakeItemsHTMLbyCount(0,gnItems);
  987.     document.body.insertAdjacentHTML("beforeEnd",sHTML);
  988.     var obj=getH6ById(0);
  989.     if (document.body != null)
  990.     {
  991.         gnVisible=Math.ceil(document.body.clientHeight/gnUHeight);
  992.     }
  993.     gaFakes[0]=new fakeItemsArea(0,gnItems,"",getEndString(),obj);
  994.     enEvt();
  995. }
  996.  
  997. function getEndString()
  998. {
  999.     var sBC=getBiggestChar();
  1000.     return sBC+sBC+sBC+sBC+sBC+sBC+sBC+sBC;
  1001. }
  1002.  
  1003. function getUnitIdx(nScrl,nHeight)
  1004. {
  1005.     if(gaFakes.length==0)
  1006.     {
  1007.         markEnd();
  1008.         return;
  1009.     }
  1010.     var nB=0;
  1011.     var nE=gaFakes.length-1;
  1012.     var nM=-1;
  1013.     var nTop=0;
  1014.     var nBtm=0;
  1015.     var bF=false;
  1016.     do{
  1017.         nM=(nB+nE)>>1;
  1018.         nBtm=gaFakes[nM].getBtm();
  1019.         nTop=gaFakes[nM].getTop();
  1020.             
  1021.         if(nTop>=nScrl+nHeight)
  1022.             nE=nM-1;
  1023.         else if(nBtm<nScrl)
  1024.             nB=nM+1;
  1025.         else{
  1026.             bF=true;
  1027.             break;
  1028.         }
  1029.     }while(nE>=nB);
  1030.     if(bF)
  1031.     {
  1032.         if(nTop>=nScrl){
  1033.             gsSKA=gaFakes[nM].sKA;
  1034.             gsSKB=null;
  1035.             gnNeeded=Math.ceil((nHeight-nTop+nScrl)/gnUHeight);
  1036.             gnIns=gaFakes[nM].nB;
  1037.             checkReady();
  1038.         }
  1039.         else if(nBtm<=nScrl+nHeight){
  1040.             gsSKB=gaFakes[nM].sKB;
  1041.             gsSKA=null;
  1042.             gnNeeded=Math.ceil((nBtm-nScrl+gnScrlMgn)/gnUHeight);
  1043.             gbNeedCalc=true;
  1044.             checkReady();
  1045.         }
  1046.         else{
  1047.             gnNeeded=gnVisible;
  1048.             var nUnitIdx=gaFakes[nM].nB+Math.floor((nScrl-nTop)/gnUHeight);
  1049.             if (!showItemsInEvaluation(nUnitIdx))
  1050.             {
  1051.                 gsSKA=gaFakes[nM].sKA;
  1052.                 gsSKB=null;
  1053.                 gnNeeded=Math.ceil(nHeight/gnUHeight);
  1054.                 gnIns=gaFakes[nM].nB;
  1055.                 checkReady();
  1056.             }
  1057.         }
  1058.     }
  1059.     else
  1060.         markEnd();
  1061. }
  1062.  
  1063. function disEvt()
  1064. {
  1065.     window.onscroll=null;
  1066.     window.onresize=null;
  1067. }
  1068.  
  1069. function enEvt()
  1070. {
  1071.     window.onscroll=window_OnScroll;
  1072.     window.onresize=window_OnResize;
  1073. }
  1074.  
  1075. function insertIdxKs(nIns,oHTML,bScrl)
  1076. {
  1077.     var bRtn=true;
  1078.     disEvt();
  1079.     var nCount=oHTML.nConsumed;
  1080.     var nB=0;
  1081.     var nE=gaFakes.length-1;
  1082.     var nM=-1;
  1083.     var bF=false;
  1084.     do{
  1085.         nM=(nB+nE)>>1;
  1086.         if(gaFakes[nM].nB>nIns)
  1087.             nE=nM-1;
  1088.         else if(gaFakes[nM].nB+gaFakes[nM].nNum<=nIns)
  1089.             nB=nM+1;
  1090.         else{
  1091.             bF=true;
  1092.             break;
  1093.         }
  1094.     }while(nE>=nB);
  1095.     if(bF)
  1096.     {
  1097.         var oFIA=gaFakes[nM];
  1098.         var nOffsetTop=oFIA.getTop();
  1099.         var nOffsetBottom=oFIA.getBtm();
  1100.         var nDelta=0;
  1101.         var nHDiff=nIns-oFIA.nB;
  1102.         var nTDiff=oFIA.nNum+oFIA.nB-(nIns+nCount);
  1103.         if(nHDiff>0)
  1104.         {
  1105.             nDelta=oFIA.setNum(nHDiff);
  1106.             var sOldKBefore=oFIA.sKB;
  1107.             oFIA.sKB=oHTML.sFK;
  1108.             if(nTDiff>0)
  1109.             {
  1110.                 var sHTML=getFakeItemsHTMLbyCount(nIns,nTDiff);
  1111.                 oFIA.insertAdjacentHTML("afterEnd",sHTML);
  1112.                 var obj=getH6ById(nIns);
  1113.                 insertItemIntoArray(gaFakes,nM+1,new fakeItemsArea(nIns+nCount,nTDiff,oHTML.sLK,sOldKBefore,obj));
  1114.             }
  1115.             oFIA.insertAdjacentHTML("afterEnd",oHTML.sHTML);    
  1116.             if(bScrl)
  1117.             {
  1118.                 if(gbMac&&gbIE4)
  1119.                 {
  1120.                     var nScrollPos=nOffsetBottom-nDelta;
  1121.                     while(document.body.scrollTop!=nScrollPos)
  1122.                         document.body.scrollTop=nScrollPos;
  1123.                 }
  1124.                 else
  1125.                     window.scrollTo(0,nOffsetBottom-nDelta);
  1126.             }
  1127.         }
  1128.         else{
  1129.             oFIA.insertAdjacentHTML("beforeBegin",oHTML.sHTML);
  1130.             if(bScrl){
  1131.                 if(gbMac&&gbIE4)
  1132.                 {
  1133.                     var nScrollPos=nOffsetTop;
  1134.                     while(document.body.scrollTop!=nScrollPos)
  1135.                         document.body.scrollTop=nScrollPos;
  1136.                 }
  1137.                 else
  1138.                     window.scrollTo(0,nOffsetTop);
  1139.             }
  1140.                     
  1141.             if(nTDiff>0)
  1142.             {
  1143.                 oFIA.nB=nIns+nCount;
  1144.                 nDelta=oFIA.setNum(nTDiff);
  1145.                 oFIA.sKA=oHTML.sLK;
  1146.             }    
  1147.             else{
  1148.                 gaFakes[nM].setNum(0);
  1149.                 removeItemFromArray(gaFakes,nM);
  1150.             }
  1151.         }
  1152.     }
  1153.     else
  1154.         bRtn=false;
  1155.     enEvt();
  1156.     return bRtn;
  1157. }
  1158.  
  1159. function window_OnScroll()
  1160. {
  1161.     gnSE++;
  1162.     setTimeout("procScroll();",50);    
  1163. }
  1164.  
  1165. function procScroll()
  1166. {
  1167.     if(gnSE==1&&!gbProcess)
  1168.     {
  1169.         markBegin();
  1170.         getUnitIdx(document.body.scrollTop,document.body.clientHeight);
  1171.     }
  1172.     gnSE--;
  1173. }
  1174.  
  1175. function window_OnResize()
  1176. {
  1177.     gnRE++;
  1178.     setTimeout("procResize();",50);
  1179. }
  1180.  
  1181. function procResize()
  1182. {
  1183.     if(gnRE==1&&!gbProcess)
  1184.     {
  1185.         markBegin();
  1186.         gnVisible=Math.ceil(document.body.clientHeight/gnUHeight);
  1187.         if(gnIns==-1)
  1188.             getUnitIdx(document.body.scrollTop,document.body.clientHeight);
  1189.     }
  1190.     gnRE--;
  1191. }
  1192.  
  1193. function getChunkByIdx(nIdx,nPosition)
  1194. {
  1195.     var oCData=null;
  1196.     if(nIdx<gaChunks.length)
  1197.     {
  1198.         var len=gaChunks[nIdx].length;
  1199.         if(len>0)
  1200.         {
  1201.             var nB=0;
  1202.             var nE=len-1;
  1203.             var bF=false;
  1204.             do{
  1205.                 var nM=(nB+nE)>>1;
  1206.                 if(nPosition<gaChunks[nIdx][nM].nTotal)
  1207.                 {
  1208.                     bF=true;
  1209.                     nE=nM;
  1210.                 }
  1211.                 else
  1212.                     nB=nM+1;
  1213.             }while(nE>nB);
  1214.             if(bF)
  1215.                 oCData=gaChunks[nIdx][nE];
  1216.             else if(nPosition<gaChunks[nIdx][nB].nTotal)
  1217.                 oCData=gaChunks[nIdx][nB];
  1218.         }
  1219.     }
  1220.     return oCData;
  1221. }
  1222.  
  1223. function getChunkedData(nIdx,bDown,sK)
  1224. {
  1225.     var oCData=null;
  1226.     var nCandId=-1;
  1227.     if(nIdx<gaChunks.length)
  1228.     {
  1229.         var len=gaChunks[nIdx].length;
  1230.         if(len>0)
  1231.         {
  1232.             var nB=0;
  1233.             var nE=len-1;
  1234.             var bF=false;
  1235.             do{
  1236.                 var nM=(nB+nE+(bDown?0:1))>>1;
  1237.                 if(bDown)
  1238.                 {
  1239.                     if(compare(sK,gaChunks[nIdx][nM].sEK)<0)
  1240.                     {
  1241.                         bF=true;
  1242.                         nE=nM;
  1243.                     }
  1244.                     else
  1245.                         nB=nM+1;
  1246.                 }
  1247.                 else
  1248.                 {
  1249.                     if(compare(sK,gaChunks[nIdx][nM].sBK)>0)
  1250.                     {
  1251.                         bF=true;
  1252.                         nB=nM;
  1253.                     }
  1254.                     else
  1255.                         nE=nM-1;
  1256.                 }
  1257.             }while(nE>nB);
  1258.             if(bF)
  1259.             {
  1260.                 if(bDown)
  1261.                     nCandId=nE;
  1262.                 else
  1263.                     nCandId=nB;
  1264.             }
  1265.             else
  1266.             {
  1267.                 if(bDown)
  1268.                 {
  1269.                     if(gaChunks[nIdx].length>nB&&compare(sK,gaChunks[nIdx][nB].sEK)<0)
  1270.                         nCandId=nB;
  1271.                     else
  1272.                         nCandId=gaChunks[nIdx].length-1;
  1273.                 }
  1274.                 else
  1275.                 {
  1276.                     if(0<=nE&&compare(sK,gaChunks[nIdx][nE].sBK)>0)
  1277.                         nCandId=nE;
  1278.                     else
  1279.                         nCandId=0;
  1280.                 }
  1281.             }
  1282.             return gaChunks[nIdx][nCandId];
  1283.         }
  1284.     }
  1285.     return null;
  1286. }
  1287.  
  1288. function findCK()
  1289. {
  1290.     if(gsCK!=null)
  1291.     {
  1292.         gsSKA=gsCK;
  1293.         gbFindCK=true;
  1294.         gnNeeded=1;
  1295.         markBegin();
  1296.         checkReady();
  1297.     }
  1298. }
  1299.  
  1300. function writeLoadingDiv(nIIdx)
  1301. {
  1302.     return "<div id=\""+gsLoadingDivID+"\" style=\"position:absolute;top:0;left:0;z-index:600;visibility:hidden;padding-left:4px;background-color:ivory;border-width:1;border-style:solid;border-color:black;width:150px;\">"+gsLoadingMsg+"</div>";
  1303. }
  1304.  
  1305. var gbWhHost=true;